// const { json } = require("express");

new Vue({
	el: '#app',
	data: function () {
		return {
			popupRemoveConfim:false,//删除确认框
			showErrorMsg:false,
			errormsg:'',
			addTimeIndex:'',
			searchDate:'',
			timevalue:'',
			addDay:'', //哪一天的日期下面进行添加排班
			loading:true,
			host: window.location.protocol+'//'+window.location.host,
			communityId:'',
			userId:'',
			msg:'',
			errorPopup:false,
			lists:'',
			nodatashow:false,
			requestHeaders:'',

		}
	},
	created() {
		this.communityId=this.getUrlParam("communityId");
		this.requestHeaders=getRequestHeaders('01',this.communityId);//获取请求头
        // console.log(this.requestHeaders)
		console.log(this.localStorageCommunityId)
		// this.searchDate=this.getUrlParam("searchDate")?this.getUrlParam("searchDate"):'';
		// this.selectTypeId=this.getUrlParam("selectTypeId")?this.getUrlParam("selectTypeId"):'';
		// this.selectTypeValue=this.getUrlParam("selectTypeValue")?this.getUrlParam("selectTypeValue"):'';
		this.listPayFeeHistory();
	},
	methods: {
		// 查询维修类型
		listPayFeeHistory(){
			var that=this;
			var url=this.host+'/app/fee.listPayFeeHistory';
			console.log('communityId:'+this.communityId)
			var params={
				communityId:this.communityId,
				row:50,
				page:1
			}
			$.ajax({
				url : url,
				type: 'GET',
				dataType:'json',
				headers:that.requestHeaders,
				data: params,
				success : function (res){
					console.log('res',res);
					if(res.code=='0'){
						if(res.data.length>0){
							that.lists=res.data;
						}else{
							that.nodatashow = true
						}
					}else{
						that.nodatashow = true
						// that.errorPopup=true;
						// that.msg=res.msg
					}
				},
				error:function(res){
					that.errorPopup=true;
					that.msg=res.responseText?res.responseText:'请求超时'
					console.log(res.responseText)

				}
			})
		},
		timeBlur(){
			var that=this;
			if(this.timevalue>0 && this.timevalue<1440){
				this.timevalue=this.getInteger(this.timevalue)
			}else{
				this.showErrorMsg=true;
				this.errormsg='时间间隔为整数且不可超过1440(分钟)';
				setTimeout(function(){
					that.showErrorMsg=false;
				},1500)
				this.timevalue='';
				return;
			}

		},
		//获取小数点前面的数字
		getInteger(num){
			var val=num.toString();
			if(val.indexOf('.')==-1){
				return val;
			}else{
				return val.substring(0,val.indexOf('.'))
			}
		},
		//时分比较
		timeComparison(start,end){
			//分割开始时间的时
			let kaiShi = start.split(":")[0];
			//分割开始时间的分
			let kaiFen = start.split(":")[1];
			//分割结束时间的时
			let jieShi = end.split(":")[0];
			//分割结束时间的分
			let jieFen = end.split(":")[1];
			//判断两者的时
			if(kaiShi < jieShi){
				return false;
			}else if(kaiShi == jieShi){
				//如果等于的话就判断两者的分
				if(kaiFen < jieFen){
					return false;
				}else{
					return true;
				}
			}else{
				return true;
			}
		},
		getUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg); //匹配目标参数
			if (r != null) return unescape(r[2]);
			return null; //返回参数值

		},

		//添加值班人员先判断维修类型是否已选
		addPeople(){
			var that=this;
			this.showErrorMsg=true;
			this.errormsg='请先选择维修类型';
			setTimeout(function(){
				that.showErrorMsg=false;
			},1500)
			return;
		},
		payHistory(){
			console.log('111')
			var url=this.host+'/userPayHistory.html?communityId='+this.communityId+'&userId='+this.userId;
			window.location.href = url;
		}
	}
});